package mx.kolobok.noteeditor.ui;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageProducer;
import java.io.IOException;

/**
 * User:  Nikita Belenkiy
 * Date: 28.05.11
 * Time: 15:41
 */
public class Icons {

    public static Icon deleteIconDefault;
    public static Icon deleteIconMouseOver;
    static {
        try {
            BufferedImage deteleIconImage = loadImage("icons/delete-default.png");
            deleteIconMouseOver = new ImageIcon(deteleIconImage);
            deleteIconDefault =new ImageIcon(createInactiveImage(deteleIconImage));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static BufferedImage loadImage(String imageResourcePath) throws IOException {
        ClassLoader classLoader = Icons.class.getClassLoader();
        return ImageIO.read(classLoader.getResourceAsStream(imageResourcePath));
    }

    public static Image createInactiveImage(Image i) {
        GrayFilter filter = new GrayFilter(true, 75);
        ImageProducer prod = new FilteredImageSource(i.getSource(), filter);
        return Toolkit.getDefaultToolkit().createImage(prod);
    }
}
